﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class UISimpleBlood
{
    private GameObject uiGameObj = null;

    public UISimpleBlood(GameObject uiGameObj)
    {
        this.uiGameObj = uiGameObj;
    }

    public void Destroy()
    {
        if (null != uiGameObj)
        {
            GameObject.Destroy(uiGameObj);
            uiGameObj = null;
        }
    }

    public void Show()
    {
        if (null != uiGameObj)
        {
            uiGameObj.SetActive(true);
        }
    }

    public void Hide()
    {
        if (null != uiGameObj)
        {
            uiGameObj.SetActive(false);
        }
    }

    public void SetValue(float value)
    {
        if (null != uiGameObj)
        {
            uiGameObj.GetComponent<Slider>().value = value;
        }
    }

    public void UpdatePosition(Vector3 position)
    {
        if (null != uiGameObj)
        {
            Vector3 screenPos = Camera.main.WorldToScreenPoint(position);

            uiGameObj.transform.position = screenPos;
        }
    }
}
